package jp.co.ricoh.melody.views.adapters;

import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.widget.AdapterView;
import android.widget.GridView;
import android.widget.ListAdapter;

import java.util.List;

import jp.co.ricoh.melody.models.IDay;
import jp.co.ricoh.melody.presenters.IDayListPresenter;
import jp.co.ricoh.melody.presenters.DayListPresenter;
import jp.co.ricoh.melody.utils.ConstantUtils;

/**
 * Copyright (C) 2016 RICOH Co.,LTD.
 * All rights reserved.
 */
public class IDayListViewImpl extends GridView implements IDayListView,AdapterView.OnItemClickListener{

    private  final IDayListPresenter mPresenter=new DayListPresenter() ;

    public IDayListViewImpl(Context context) {
        super(context);
    }

    public IDayListViewImpl(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    @Override
    public void onCreate() {
        mPresenter.onCreate(this);
        setNumColumns(ConstantUtils.DAY_OF_WEEK);
        setOnItemClickListener(this);


    }


    @Override
    public void setListAdapter(ListAdapter adapter) {
        setAdapter(adapter);

    }

    @Override
    public Context getViewContext() {
        return getContext();
    }

    @Override
    public List<IDay> getDays() {
        return mPresenter.getDays();
    }

    @Override
    public void updateDay(int position, boolean logic) {
        mPresenter.updateDay(position, logic);
    }

    @Override
    public void updateAllDay(boolean[] logic) {
        mPresenter.updateAllDay(logic);
    }

    @Override
    public boolean[] getDaysRepeat() {
        return mPresenter.getDaysRepeat();
    }

    @Override
    public boolean selectedDay() {
        return mPresenter.selectedDay();
    }

    @Override
    public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
        mPresenter.onItemClick(i);
        mPresenter.onListUpdate();

    }
}
